import {Component, EventEmitter, Input, Output} from '@angular/core';
import {NavController, ViewController} from 'ionic-angular';
import {SystemService} from "../../pages/service/SystemService";
import {UserManager} from "../../framework/manager/UserManager";

//import {Service} from "../../pages/service/Service";

@Component({
    selector: 'singlelist',
    templateUrl: 'singleList.html'
})
export class SingleList {
    @Input() dataList:any=[];
    @Input() title: string;
    @Input() type:number;
    relationship:string;
    value:string;
    year:any;
    unitName:any;
    private branchId: string;
    constructor(public navCtrl: NavController,public view: ViewController) {
        this.year = UserManager.getInstance().user.year;
        this.unitName = UserManager.getInstance().user.unitName;
        this.branchId = UserManager.getInstance().user.branchId;

    }
    sureHandler(){
        let newItem = {
            title: this.title,
            value:this.value
        };
        this.view.dismiss(newItem);
    }

    chooseResult(name,id,unitId){
        this.value =name;
        UserManager.getInstance().user.unitName=name;
        UserManager.getInstance().user.unitId = unitId;
        UserManager.getInstance().user.branchId=id;

        this.sureHandler();
    }
    chooseYearResult(name){
        this.value =name;

        UserManager.getInstance().user.year = name;
        console.log(UserManager.getInstance().user.year);
        this.sureHandler();

    }
}

